Source File
axis.go
Belonging Package
github.com/K-Phoen/grabana/timeseries/axis
package axisimport ()// PlacementMode represents the axis display placement mode.type PlacementMode stringconst (Hidden PlacementMode = "hidden"Auto PlacementMode = "auto"Left PlacementMode = "left"Right PlacementMode = "right")// ScaleMode represents the axis scale distribution.type ScaleMode uint8const (Linear ScaleMode = iotaLog2Log10)// Option represents an option that can be used to configure an axis.type Option func(axis *Axis) error// Axis represents a visualization axis.type Axis struct {fieldConfig *sdk.FieldConfig}// New creates a new Axis configuration.func ( *sdk.FieldConfig, ...Option) (*Axis, error) {:= &Axis{fieldConfig: }for , := range {if := (); != nil {return nil,}}return , nil}// Placement defines how the axis should be placed in the panel.func ( PlacementMode) Option {return func( *Axis) error {.fieldConfig.Defaults.Custom.AxisPlacement = string()return nil}}// SoftMin defines a soft minimum value for the axis.func ( int) Option {return func( *Axis) error {.fieldConfig.Defaults.Custom.AxisSoftMin = &return nil}}// SoftMax defines a soft maximum value for the axis.func ( int) Option {return func( *Axis) error {.fieldConfig.Defaults.Custom.AxisSoftMax = &return nil}}// Min defines a hard minimum value for the axis.func ( float64) Option {return func( *Axis) error {.fieldConfig.Defaults.Min = &return nil}}// Max defines a hard maximum value for the axis.func ( float64) Option {return func( *Axis) error {.fieldConfig.Defaults.Max = &return nil}}// Unit sets the unit of the data displayed in this series.func ( string) Option {return func( *Axis) error {.fieldConfig.Defaults.Unit =return nil}}// Scale sets the scale to use for the Y-axis values..func ( ScaleMode) Option {return func( *Axis) error {:= struct {string `json:"type"`int `json:"log,omitempty"`}{: "linear",}switch {case Linear:. = "linear"case Log2:. = "log". = 2case Log10:. = "log". = 10}.fieldConfig.Defaults.Custom.ScaleDistribution =return nil}}// Label sets a Y-axis text label.func ( string) Option {return func( *Axis) error {.fieldConfig.Defaults.Custom.AxisLabel =return nil}}// Decimals sets how many decimal points should be displayed.func ( int) Option {return func( *Axis) error {if < 0 {return fmt.Errorf("decimals must be greater than 0: %w", errors.ErrInvalidArgument)}.fieldConfig.Defaults.Decimals = &return nil}}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |